import { log } from "console";
import { Directive, DirectiveBinding } from "vue";
interface VLazy {
  value: string;
  loading: string;
}
const vLazy: Directive<HTMLImageElement, VLazy> = async (el, bingding) => {
  const def = await import(bingding.value.loading);
  console.log(bingding.value);

  el.src = def.default;
  const obServer = new IntersectionObserver((entries) => {
    if (entries[0].intersectionRatio > 0) {
      el.src = bingding.value.value;

      obServer.unobserve(el);
    }
  });
  obServer.observe(el);
};
export default vLazy;
